<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<!-- http://127.0.0.1:8080/company/web/login.jsp -->
<%@ include file="/web/header.jsp" %>
<title>login</title>
</head>
<body>
	<fieldset class="layui-elem-field" style='margin:20px;padding:20px'>
	  <legend>系统登录</legend>
	  <div class="layui-field-box">
	   	<form class="layui-form layui-form-pane" action="">
		  <div class="layui-form-item">
		    <label class="layui-form-label">账号</label>
		    <div class="layui-input-inline">
		      <input type="text" name="code" required  lay-verify="required" placeholder="请输入帐号" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">密码框</label>
		    <div class="layui-input-inline">
		      <input type="password" name="psd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">
		      <img src='/company/VerifyCodeServlet' onclick="this.src='/company/VerifyCodeServlet?'+Math.random();"/>
			</label>
		    <div class="layui-input-inline">
		      <input type="text" name="yzm" required  lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-inline">
			  <input type="button" class="layui-btn" lay-submit lay-filter="login" value="登录">		   
		      <input type="reset" class="layui-btn layui-btn-primary" value="重置">
		    </div>
		    <input type="button" class="layui-btn" value="跳转注册" onclick="toJsp('/web/reg.jsp')">
		  </div>
		  <input type="hidden" name="action" value="login"/>
		</form>
	  </div>
</fieldset>
<script type="text/javascript">
// function toJspReg(){
// 	location.href=base.app+"/web/reg.jsp"
// }

// 	var form=layui.form;
// 	var layer=layui.layer;
// 	var $=layui.jquery;
// 	form.on("submit(login)",function(data){//给按钮加监听，执行方法
// 		console.log(data.field);
// 		$.ajax({
// 			url:base.app+"/employee",
// 			type:"post",
// 			data:data.field,
// 			dataType:"text",
// 			success:function(data){ 
// 				console.log(data);
// 				if("0"==data){
// 					layer.msg("账号不存在")
// 				}else if("1"==data){
// 					layer.msg("登录成功")
// 				}else if("F"==data){
// 					layer.msg("验证码错误")
// 				}else{
// 					layer.msg("密码错误")
// 				}
// 			}
// 		})
// 	})
	
	formOn("/employee",'submit(login)',"text",function(data){
	console.log(data)
		if("0"==data){
		    layer.msg("账号不存在")
		}else if("1"==data){//2秒关闭，默认3秒
		    layer.msg("登录成功",{time:2000},function(){
				toJsp("/web/page/main.jsp")
			})
		}else if("F"==data){
			layer.msg("验证码错误")
		}else{
			layer.msg("密码错误")
		}
})
</script>
</body>
</html>